package com.yufeng.learning.client.config;

import com.netflix.client.config.IClientConfig;
import com.netflix.loadbalancer.AvailabilityFilteringRule;
import com.netflix.loadbalancer.IPing;
import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.PingUrl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;

//自定义Ribbon Client配置，可用的Bean：
// an IClientConfig, which stores client configuration for a client or load balancer,
//an ILoadBalancer, which represents a software load balancer,
//a ServerList, which defines how to get a list of servers to choose from,
//an IRule, which describes a load balancing strategy, and
//an IPing, which says how periodic pings of a server are performed.

public class GreetingRibbonConfiguration {
    @Autowired
    IClientConfig ribbonConfig;

    @Bean
    public IPing pingUrl() {
        return new PingUrl();
    }
    @Bean
    public IRule ribbonRule() {
        return new AvailabilityFilteringRule();
    }

}
